package com.ygxsk.carhome.retrofit;

/*
 * @Author:itchenqi
 * @Time:2022-10-25  14:48
 * @Description: 报错的信息，将原始json传递过来最好
 */
public class ApiException extends Exception {

    private String displayCode;
    private String displayMessage;

    /**
     * 为了做日志上传的操作
     */
    private ApiRequestSubListener apiRequestSubListener;

    private AddLogUpLoadInfo addLogUpLoadInfo;


    public ApiException(String _displayCode,//
                        String _displayMessage,//
                        AddLogUpLoadInfo _addLogUpLoadInfo,//
                        ApiRequestSubListener _apiRequestSubListener) {//

        this.displayCode = _displayCode;
        this.displayMessage = _displayMessage;
        this.addLogUpLoadInfo = _addLogUpLoadInfo;
        this.apiRequestSubListener = _apiRequestSubListener;

    }

    public ApiException(String _displayCode, String _displayMessage) {
        this.displayCode = _displayCode;
        this.displayMessage = _displayMessage;
    }


    public String getDisplayCode() {
        return displayCode;
    }

    public void setDisplayCode(String displayCode) {
        this.displayCode = displayCode;
    }

    public String getDisplayMessage() {
        return displayMessage;
    }

    public void setDisplayMessage(String displayMessage) {
        this.displayMessage = displayMessage;
    }

    public AddLogUpLoadInfo getAddLogUpLoadInfo() {
        return addLogUpLoadInfo;
    }

    public void setAddLogUpLoadInfo(AddLogUpLoadInfo addLogUpLoadInfo) {
        this.addLogUpLoadInfo = addLogUpLoadInfo;
    }

    public ApiRequestSubListener getApiRequestSubListener() {
        return apiRequestSubListener;
    }

    public void setApiRequestSubListener(ApiRequestSubListener apiRequestSubListener) {
        this.apiRequestSubListener = apiRequestSubListener;
    }

    //这里暂时不做处理
//    public  void handlerOnExceptionRequest(Exception e) {
//        //直接处理日志的
//        //    //再定义一个直接上传日志的方法
//        if (apiRequestSubListener != null) {
//            //发生了请求，但是发现请求报错，如果界面处理 onExceptionRequest 就提示给用户；
//            if (addLogUpLoadInfo.isToastToUser()) {
//                //如果提示给用户 就一起提示
//                apiRequestSubListener.onExceptionRequest(addLogUpLoadInfo.getWhat(), addLogUpLoadInfo.getActivity(), e);
//            }
//        }
//    }

//    /**
//     * 直接上传日志信息
//     */
//    public void uploadAddLog(String lablel, Exception e) {
//
//        if (apiRequestSubListener != null) {
//
//            if (addLogUpLoadInfo != null) {
//                apiRequestSubListener.addLogInApiRequestListener(addLogUpLoadInfo.getActivity(),//
//                        addLogUpLoadInfo.getUrlPath(),//
//                        addLogUpLoadInfo.getRequestMethod(),//
//                        addLogUpLoadInfo.getHashMapParameter(),//
//                        lablel + "-->" + CommUtils.addLogFormatException(e));//
//            }
//
//        }
//
//    }

}
